/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com 

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef TRI_NODE_H_
#define TRI_NODE_H_

#include <stdlib.h>
#include <iostream>
#include <assert.h>

namespace tri{
namespace node{


class Node{
public:
    Node();
    virtual ~Node();

    /**
     * Get the previous node ptr.
     * @note This can be NULL.
     */
    Node* getPrevNode();
    
    /**
     * Get the next node ptr.
     * @note This can be NULL.
     */
    Node* getNextNode();
    
    /**
     * Get the child node ptr.
     * @note This can be NULL.
     */
    Node* getChildNode();
    
    
    
    bool compareNodeID(Node* n);
    
    /**
     * Add a node to the node list
     */
    void addNode(Node* n);
    
    /**
     * Returns true is  the node is part of the
     * child link list.
     */
    bool inChildNode(Node* n);
    
    /**
     * Recurively check if the node is a child of a child
     * until the nth child.
     */
    bool inChildNodeRecursive(Node* n);
    
    /**
     * Remove node from child link list
     */
    void removeNode(Node* n);
    
    /**
     * Get the leaf node if there is one.
     */
    Node* getLeafNode();
    
    /**
     * Get the root node for the Node list
     * containing this node.
     * Returns NULL if this node is not part of a list
     */
    Node* getRootNode();

    
private:
    
    
    
    Node* prev_node;
    Node* next_node;
    Node* child_node;
    
    static unsigned int node_count;
    unsigned int node_id;
};

}


}
#endif
